package Ioperate;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class CheckBook implements Ioperate{
    public void work(BookList bookList){
        Scanner scanner = new Scanner(System.in);
        int count = bookList.getSize();

        System.out.println("请输入书名：");
        String name = scanner.nextLine();
        int i = 0;
        for (i = 0; i < count; i++) {
            if(bookList.getBooks(i).getName().equals(name)){
                Book book = bookList.getBooks(i);
                System.out.println(book);
                System.out.println();
                return ;
            }
            if(i==count) {
                System.out.println("未找到此书！");
            }
        }
    }
}
